package com.blogspot.mikelaud.cbs;

import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;

public class SrcFilenamesGenerator extends SimpleFileVisitor<Path> {

	private StringBuilder mOutputBuilder = new StringBuilder();
	private StringBuilder mDirectoryBuilder = new StringBuilder();
	private String mDirectory = "";
	
	@Override
    public FileVisitResult preVisitDirectory(Path aFile, BasicFileAttributes aAttributes) {
		mDirectoryBuilder.append(aFile.getFileName());
		mDirectoryBuilder.append("/");
		mDirectory = mDirectoryBuilder.toString();
        return FileVisitResult.CONTINUE;
    }
	
	@Override
	public FileVisitResult visitFile(Path aFile, BasicFileAttributes aAttributes) {
		mOutputBuilder.append(mDirectory);
		mOutputBuilder.append(aFile.getFileName());
		mOutputBuilder.append(" ");
		return FileVisitResult.CONTINUE;
	}
	
	public String getSrcFilenames() {
		return mOutputBuilder.toString();
	}
	
}
